Skip to content

Conversation

@kowkowalski
Copy link

100% coverage for Burger — диплом часть 1

.idea/misc.xml Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Папку .idea не нужно было загружать в репозиторий. Эта папка должна быть добавлена в .gitignore.


burger.setBuns(bun);

assertEquals("black bun", burger.bun.getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Для юнит-тестов придерживаемся подхода: один тест, значит одна проверка. Если очень хочется несколько проверок -- тогда используем softAssertions. Поправь, пожалуйста, во всем коде

}

@Test
public void setBuns_shouldAssignBun() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Неверный нейминг. Не используем спецсимволы в названии методов

public void removeIngredient_shouldRemoveFromList() {
Burger burger = new Burger();
burger.setBuns(new Bun("default", 50.0f));
Ingredient ingredient = new Ingredient(IngredientType.FILLING, "cheese", 40.0f);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Для всех зависимостей нужно использовать моки


String receipt = burger.getReceipt();

assertTrue(receipt.contains("(==== black bun ====)"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Строку рецепта нужно проверять целиком, чтобы не пропустить ошибки форматирования

String expectedPriceLine = String.format("Price: %f", burger.getPrice());
assertTrue(receipt.contains(expectedPriceLine));
}
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Нужно написать параметризированные тесты.

private Bun bunMock;

@Mock
private Ingredient ingredientMock1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. При нейминге не рекомендуется использовать числа (Field2), их еще называют magicNumbers. Очень тяжело поддерживать код с magicNumbers.

Ingredient ingredient = new Ingredient(type, name, price);
assertEquals(price, ingredient.getPrice(), 0.0001f);
}
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔️Нужно исправить. Нужно приложить отчет о тестировании

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants